using RBAC.Domain.RBAC;

namespace RBAC.Interstructrue.Base
{
    /// <summary>
    /// 角色仓储接口
    /// </summary>
    public interface IRoleRepository : IBaseRepository<RoleModel>
    {
        /// <summary>
        /// 创建角色及其权限关联（事务操作）
        /// </summary>
        /// <param name="role">角色信息</param>
        /// <param name="permissionIds">权限ID列表</param>
        /// <returns>角色ID</returns>
        int CreateRoleWithPermissions(RoleModel role, List<long>? permissionIds);
        
        /// <summary>
        /// 更新角色及其权限关联（事务操作）
        /// </summary>
        /// <param name="role">角色信息</param>
        /// <param name="permissionIds">权限ID列表</param>
        /// <returns>影响的行数</returns>
        int UpdateRoleWithPermissions(RoleModel role, List<long>? permissionIds);
        
        /// <summary>
        /// 删除角色及其所有关联（事务操作）
        /// </summary>
        /// <param name="roleId">角色ID</param>
        /// <returns>影响的行数</returns>
        int DeleteRoleWithAllRelations(long roleId);
        
        /// <summary>
        /// 检查角色名是否已存在
        /// </summary>
        /// <param name="roleName">角色名</param>
        /// <param name="excludeId">排除的角色ID（用于更新时检查）</param>
        /// <returns>是否存在</returns>
        bool IsRoleNameExists(string roleName, long excludeId = 0);
    }
} 